package com.hlwxy.ssm.excel;

import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import java.io.FileOutputStream;

public class ExcelTest {
    public static void main(String[] args) throws Exception {
        //创建工作簿
        HSSFWorkbook wb = new HSSFWorkbook();
        //创建工作表
        HSSFSheet sheet = wb.createSheet("hello word");
        //创建excel行
        HSSFRow row = sheet.createRow((short)0);
        //创建excel列
        row.createCell((short)0).setCellValue("你好word");


        //文件写入
        String filename = "d:/s1/测试.xls";
                  if (wb instanceof HSSFWorkbook) {
                          filename = filename + "x";
                       }

                FileOutputStream out = new FileOutputStream(filename);
                   wb.write(out);
                   out.close();
    }
}
